package com.likeyoudo.views.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.likeyoudo.views.fragment.ImagePreviewFragment;

import java.util.List;

/**
 * @author LikeYouDo
 * @date 2024/1/8 16:29
 */
public class ImagePreviewFragmentAdapter extends FragmentStateAdapter {

    private final List<ImagePreviewFragment> imagePreviewFragmentList;

    public ImagePreviewFragmentAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle, List<ImagePreviewFragment> imagePreviewFragmentList) {
        super(fragmentManager, lifecycle);
        this.imagePreviewFragmentList = imagePreviewFragmentList;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return imagePreviewFragmentList.get(position);
    }

    @Override
    public int getItemCount() {
        return imagePreviewFragmentList.size();
    }
}
